package com.xzy.b;

import com.xzy.service.BookService;
import com.xzy.service.CourseService;
import com.xzy.service.SchoolService;
import com.xzy.service.TeacherService;
import lombok.extern.slf4j.Slf4j;

/**
 * 依赖注入的方式：<constructor-arg/> + 构造方法
 *
 * @author xzy
 * @date 2021/12/6  22:17
 */
@Slf4j
public class BbbServiceImpl {
    private BookService bookService;
    private CourseService courseService;
    private SchoolService schoolService;
    private TeacherService teacherService;

    /**
     * Spring容器根据 <constructor-arg/>标签到Bean容器中寻找构造方法，
     * 如果找不到则抛出异常，如果找得到则调用构造方法注入指定的依赖
     */

    public BbbServiceImpl() {
        log.info("实例化 => BbbServiceImpl()");
    }

    public BbbServiceImpl(BookService bookService, CourseService courseService) {
        this.bookService = bookService;
        this.courseService = courseService;
        log.info("实例化 => BbbServiceImpl({}, {}})", bookService, courseService);
    }

    public void setSchoolService(SchoolService schoolService) {
        this.schoolService = schoolService;
        log.info("依赖注入 --> setSchoolService({})", schoolService);
    }

    public void setTeacherService(TeacherService teacherService) {
        this.teacherService = teacherService;
        log.info("依赖注入 --> setTeacherService({})", teacherService);
    }
}
